AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
 
include('shared.lua')

function ENT:Initialize()
	self:SetModel( INV_POWERCOREMODEL )
	self:PhysicsInit( SOLID_VPHYSICS )      -- Make us work with physics,
	self:SetMoveType( MOVETYPE_VPHYSICS )   -- after all, gmod is a physics
	self:SetSolid( SOLID_VPHYSICS ) 
	self:SetHullType(HULL_LARGE)
	self:SetColor( INV_POWERCORECOLOR[1], INV_POWERCORECOLOR[2], INV_POWERCORECOLOR[3], INV_POWERCORECOLOR[4] )
	constraint.Weld(self,ents.FindByClass("worldspawn")[1],0,0,0,true) --And weld the manhack to the entity
	
	self:SetHealth(INV_POWERCOREHEALTH)
end

function ENT:OnTakeDamage(dmg)
	local effectdata = EffectData()
	effectdata:SetEntity(self.Entity)
	util.Effect( "propspawn", effectdata )	

	if dmg.GetInflictor(dmg):IsNPC() == true then
		self:SetHealth(self:Health() - dmg:GetDamage())
		if self:Health() <= 0 then
			GameOver()
			self:Remove()	
		end
		
	else
		--print("Something other than an NPC hit the powercore!")
	end
end 

